function [ObjCalcProps]=CalculateObjectProperties(ObjectToScore,TrajBin,params)
%ON=params.ON;
%CP=params.CP;
BinXLim=params.binnedDimensions(1);
BinYLim=params.binnedDimensions(2);

%Find the Location in the TrajBin that the current object is most
%similar to.

[BinX BinY]=getBinCoords(ObjectToScore(params.ON.CentroidX:params.ON.CentroidY),params.binSize);
BinXC=[BinX-1,BinX,BinX+1];
BinYC=[BinY-1,BinY,BinY+1];
BinXCV=BinXC(BinXC > 0 & BinXC <= BinXLim);
BinYCV=BinYC(BinYC > 0 & BinYC <= BinYLim);

TrajToConsider=vertcat(TrajBin{BinXCV,BinYCV});
%Score the current object with all located trajectories
if(~isempty(TrajToConsider))
    %Field to contain all the trajectories near the current object
    [rows cols]=size(TrajToConsider);
    %A matrix with three columns, one for scores between the object and
    %trajectories, one for trajectory numbers and one for a sign to determine
    %if the trajectory is still under consideration for this object  This is
    %important when two objects have a best match to a trajectory.  When this
    %conflict arises the poorer matching object will have the
    %active index for the trajectory set to false
    ObjCalcProps=ones(rows,3);
    ObjCalcProps(:,params.CP.trajNumber)=TrajToConsider(:,params.ON.Number);
    
    ObjCalcProps(:,params.CP.score)=mexModWillsMetric(TrajToConsider,ObjectToScore,...
        params.AvCellBox,params.alpha,params.beta,params.epsilon,params.gamma,params.ON);   
else
    ObjCalcProps=zeros(1,3);
end
    